package com.test.ddaidai.main_account_inverst;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;

import com.test.ddaidai_android.activity.R;

public class TabActivity1 extends Activity {

	ListView inverst_project_lv;
	List<Integer> list;
	int[] colors = new int[] { R.color.inverst_project_bg1, R.color.inverst_project_bg2 };
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tab1);
		inverst_project_lv = (ListView) findViewById(R.id.inverst_project_lv);
		list = new ArrayList<Integer>();
		for (int i = 0; i < 4; i++) {
			list.add(i);
		}
		InverstAdapter adapter = new InverstAdapter();
		inverst_project_lv.setAdapter(adapter);
	}
	
class InverstAdapter extends BaseAdapter {
		
		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return list.size();
		}

		@Override
		public Object getItem(int arg0) {
			// TODO Auto-generated method stub
			return list.get(arg0);
		}

		@Override
		public long getItemId(int arg0) {
			// TODO Auto-generated method stub
			return arg0;
		}

		@Override
		public View getView(int arg0, View arg1, ViewGroup arg2) {
			// TODO Auto-generated method stub
			arg1 = getLayoutInflater().inflate(R.layout.inverstproject_item, null);
			int colorPos = arg0 % colors.length;
//			arg1.setBackgroundColor(colors[colorPos]);
			arg1.setBackgroundResource(colors[arg0%2]);
			return arg1;
		}
	}
	
}
